package sps.admin.util;

import sps.admin.module.system.login.domain.RequestEmployee;
import sps.base.common.domain.RequestUser;
import sps.base.common.util.SmartRequestUtil;

import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
import java.util.Date;

/**
 * admin 端的请求工具类
 * @Author 江苏圣普斯安防科技有限公司
 * @Date 2023/7/28 19:39:21
 * @Copyright  <a href="">江苏圣普斯安防科技有限公司</a>
 */
public final class AdminRequestUtil {


    public static RequestEmployee getRequestUser() {
        return (RequestEmployee) SmartRequestUtil.getRequestUser();
    }

    public static Long getRequestUserId() {
        RequestUser requestUser = getRequestUser();
        return null == requestUser ? null : requestUser.getUserId();
    }

    public static void main(String[] args) {

        try {
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
            String time1 = "07:57";
            String time2 = "17:06";
            Date date1 = sdf.parse(time1);
            Date date2 = sdf.parse(time2);
            long diff = date2.getTime() - date1.getTime();// 计算两个时间的差异，单位为毫秒
            long hoursDiff = diff / (30 * 60 * 1000);  // 将差异转换为半小时
            System.out.println(time1.compareTo("11:30"));
            System.out.println(time2.compareTo("18:00"));
            if(time1.compareTo("11:30") == -1 ){
                hoursDiff+=-2;
            }
            if (time2.compareTo("18:00") == 1) {
                hoursDiff+=-2;
            }
            System.out.println("差异为 " + (hoursDiff/2+(hoursDiff%2==1?".5":"")) + " 半小时");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }



}
